import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'Login',
      component: () => import('../views/Login.vue'),
    },
    {
      path: '/Main',
      name: 'Main',
      component: () => import('../views/Main.vue'),
      children:[
        {
          path: '/AdminSetting',
          name: 'AdminSetting',
          component: () => import('../views/BasicData/AdminSetting.vue'),
        },
        {
          path: '/GridPerson',
          name: 'GridPerson',
          component: () => import('../views/BasicData/GridPerson.vue'),
        },
        {
          path: '/GridType',
          name: 'GridType',
          component: () => import('../views/BasicData/GridType.vue'),
        },
        {
          path: '/Log',
          name: 'Log',
          component: () => import('../views/BasicData/Log.vue'),
        },

        //网格化管理
        {
          path: '/GridZero',
          name: 'GridZero',
          component: () => import('../views/GridManage/GridZero.vue'),
        },
        {
          path: '/GridOne',
          name: 'GridOne',
          component: () => import('../views/GridManage/GridOne.vue'),
        },
        {
          path: '/GridTwo',
          name: 'GridTwo',
          component: () => import('../views/GridManage/GridTwo.vue'),
        },
        {
          path: '/GridThree',
          name: 'GridThree',
          component: () => import('../views/GridManage/GridThree.vue'),
        },
        {
          path: '/GridFour',
          name: 'GridFour',
          component: () => import('../views/GridManage/GridFour.vue'),
        },
        {
          path: '/AreaTree',
          name: 'AreaTree',
          component: () => import('../views/GridManage/AreaTree.vue'),
        },
        {
          path: '/PhysicalGrid',
          name: 'PhysicalGrid',
          component: () => import('../views/GridManage/PhysicalGrid.vue'),
        },
        {
          path: '/LogicGrid',
          name: 'LogicGrid',
          component: () => import('../views/GridManage/LogicGrid.vue'),
        },
        {
          path: '/UnitGrid',
          name: 'UnitGrid',
          component: () => import('../views/GridManage/UnitGrid.vue'),
        },
        {
          path: '/DutyGrid',
          name: 'DutyGrid',
          component: () => import('../views/GridManage/DutyGrid.vue'),
        },
        {
          path: '/GridTeam',
          name: 'GridTeam',
          component: () => import('../views/GridManage/GridTeam.vue'),
        },
        {
          path: '/Map',
          name: 'Map',
          component: () => import('../views/GridMap/Map.vue'),
        },
        {
          path: '/SelectedMap',
          name: 'SelectedMap',
          component: () => import('../views/GridMap/SelectedMap.vue'),
        },
      ]
    },
  
  ],
}) 
//导航守卫
router.beforeEach((to,from,next)=>{
  if(to.name!="Login" &&(localStorage.getItem("Role_Name")||"")=="")
  {
     next("/");
  }
  else next();
})
export default router
